package com.janushuang.algorithm.sort;

/**
 * @author zhijing.huang
 *         Created by zhijing.huang on 2014/9/26.
 */
public class SelectionSort implements Sort {
    @Override
    public void sort(int[] data) {
        for (int i = 0; i < data.length; i++) {
            int lowIndex = i;
            for (int j = data.length-1; j > i; j--) {
                if (data[j] < data[lowIndex]) {
                    lowIndex = j;
                }
            }
            SortUtils.swap(data,i,lowIndex);
        }
    }
}
